package com.rs.game.player.content;

import java.util.concurrent.TimeUnit;

import com.rs.cores.CoresManager;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.utils.Utils;

public final class DonatorZone {

	private static enum Rocks {
		TIN_ROCK_(new WorldObject(11933, 10, 0, 5892, 4664, 1)),

		COPPER_ROCK(new WorldObject(11937, 10, 0, 5893, 4664, 1)),
		
		IRON_ROCK(new WorldObject(37307, 10, 0, 5894, 4664, 1)),
		
		COAL_ROCK(new WorldObject(11930, 10, 0, 5895, 4664, 1)),
		
		GOLD_ROCK(new WorldObject(37310, 10, 0, 5896, 4664, 1)),
		
		MITHRIL_ROCK(new WorldObject(11942, 10, 0, 5897, 4664, 1)),
		
		ADAMANTITE_ROCK(new WorldObject(11941, 10, 0, 5898, 4664, 1)),
		
		RUNITE_ROCK(new WorldObject(14859, 10, 0, 5899, 4664, 1));

		private Rocks(WorldObject rock) {
			this.rock = rock;
		}

		private WorldObject rock;

	}

	private DonatorZone() {

	}

	private static void respawnRock(final Rocks rock) {
		World.spawnObject(rock.rock, false);
		CoresManager.slowExecutor.schedule(new Runnable() {

			@Override
			public void run() {
				removeRock(rock);
			}
		}, Utils.random(8) + 3, TimeUnit.MINUTES);
	}

	private static void removeRock(final Rocks rock) {
		World.destroySpawnedObject(rock.rock, false);
		CoresManager.slowExecutor.schedule(new Runnable() {
			@Override
			public void run() {
				respawnRock(rock);
			}

		}, 10, TimeUnit.SECONDS);
	}

	public static void init() {
		for (Rocks rock : Rocks.values())
			respawnRock(rock);
	}
}
